package os.filesystem;

import java.io.File;

import os.filesystem.tool.MkDir;
import os.filesystem.utils.FSProperties;
import os.filesystem.utils.SanitizationUtil;

public class FSBootstrap {
		
	private static File disk = new File(FSProperties.getProperty(FSProperties.DISK_LOCATION));
	
	static void bootstrap(){
		//check whether disk is created
		if(!disk.exists()){
			disk.mkdirs();
		}else{
			//if disk is created, clean it up.
			SanitizationUtil.deleteAllFiles(FSProperties.getProperty(FSProperties.DISK_LOCATION));
		}
		
		//create root directory
		MkDir mkdir = new MkDir();
		mkdir.mkrootdir();
	}
	
	static void unstrap(){
		if(disk.exists()){
			SanitizationUtil.deleteAllFiles(FSProperties.getProperty(FSProperties.DISK_LOCATION));
			disk.deleteOnExit();
		}
	}
}
